package com.info.zhiduoduo.core.service.wxmessage;

import com.baomidou.mybatisplus.mapper.Condition;
import com.google.common.collect.Lists;
import com.info.zhiduoduo.common.configs.CommonConfig;
import com.info.zhiduoduo.common.configs.NotificationConfig;
import com.info.zhiduoduo.common.configs.PayConfig;
import com.info.zhiduoduo.common.configs.RechargeNotifyConfig;
import com.info.zhiduoduo.common.configs.WhetherTestConfig;
import com.info.zhiduoduo.common.configs.ZddUrlConfig;
import com.info.zhiduoduo.common.constants.Constants;
import com.info.zhiduoduo.common.constants.crowdsource.CrowdsourceUserType;
import com.info.zhiduoduo.common.constants.email.EmailType;
import com.info.zhiduoduo.common.constants.maker.MakerBidState;
import com.info.zhiduoduo.common.constants.maker.MakerEntrustTaxVideoState;
import com.info.zhiduoduo.common.constants.maker.MakerType;
import com.info.zhiduoduo.common.constants.project.ProjectType;
import com.info.zhiduoduo.common.constants.system.UserType;
import com.info.zhiduoduo.common.utils.ContextUtil;
import com.info.zhiduoduo.common.utils.DateUtil;
import com.info.zhiduoduo.common.utils.NumberUtil;
import com.info.zhiduoduo.common.utils.StringUtil;
import com.info.zhiduoduo.repository.dto.company.CompanyOfflineRechargeDetailDto;
import com.info.zhiduoduo.repository.dto.company.CompanyRechargeDto;
import com.info.zhiduoduo.repository.dto.maker.MakerDetailDto;
import com.info.zhiduoduo.repository.dto.partner.PartnerDetailDto;
import com.info.zhiduoduo.repository.dto.project.ProjectCompanyDto;
import com.info.zhiduoduo.repository.entity.company.*;
import com.info.zhiduoduo.repository.entity.complaint.Complaint;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceProject;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceProjectItem;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceTradeRecordItem;
import com.info.zhiduoduo.repository.entity.invoice.Invoice;
import com.info.zhiduoduo.repository.entity.maker.Maker;
import com.info.zhiduoduo.repository.entity.maker.MakerAccount;
import com.info.zhiduoduo.repository.entity.maker.MakerAuthRecord;
import com.info.zhiduoduo.repository.entity.maker.MakerRescissionApply;
import com.info.zhiduoduo.repository.entity.maker.MakerStudio;
import com.info.zhiduoduo.repository.entity.maker.MakerZddProjectBid;
import com.info.zhiduoduo.repository.entity.order.OrderProduct;
import com.info.zhiduoduo.repository.entity.order.TradeRecord;
import com.info.zhiduoduo.repository.entity.partner.Partner;
import com.info.zhiduoduo.repository.entity.partner.PartnerAccount;
import com.info.zhiduoduo.repository.entity.partner.PartnerStudioWithdraw;
import com.info.zhiduoduo.repository.entity.partner.PartnerWithdraw;
import com.info.zhiduoduo.repository.entity.pay.PaymentMerchant;
import com.info.zhiduoduo.repository.entity.system.BusinessManager;
import com.info.zhiduoduo.repository.entity.taxer.TaxerInvoice;
import com.info.zhiduoduo.repository.entity.weixin.WxNotice;
import com.info.zhiduoduo.repository.mapper.company.CompanyMapper;
import com.info.zhiduoduo.repository.mapper.company.CompanyOfflineRechargeDetailMapper;
import com.info.zhiduoduo.repository.mapper.company.CompanyRechargeMapper;
import com.info.zhiduoduo.repository.mapper.maker.MakerMapper;
import com.info.zhiduoduo.repository.mapper.maker.MakerStudioMapper;
import com.info.zhiduoduo.repository.mapper.order.TradeRecordMapper;
import com.info.zhiduoduo.repository.mapper.system.ManagerMapper;
import com.info.zhiduoduo.repository.mapper.system.SystemDictMapper;
import com.info.zhiduoduo.wxsdk.WxApiService;
import com.info.zhiduoduo.wxsdk.domain.app.WxTempleteMessage;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

import javax.annotation.Resource;

/**
 *  微信消息
 */
@Service("wxMessageService")
public class WxMessageServiceImpl extends BaseWxMessageService {

	@Autowired
	WxApiService wxApiService;

	@Autowired
	TradeRecordMapper tradeRecordMapper;
	@Autowired
	MakerMapper makerMapper;
	@Autowired
	MakerStudioMapper makerStudioMapper;
	@Autowired
	CompanyRechargeMapper companyRechargeMapper;
	@Autowired
	CompanyOfflineRechargeDetailMapper companyOfflineRechargeDetailMapper;
	@Resource
	private SystemDictMapper systemDictMapper;
	@Resource
	private ManagerMapper managerMapper;
	@Resource
	private CompanyMapper companyMapper;

	@Autowired
	RechargeNotifyConfig rechargeNotifyConfig;
	@Resource
	WhetherTestConfig whetherTestConfig;
	@Autowired
	PayConfig payConfig;
	@Autowired
	CommonConfig commonConfig;
	@Autowired
	ZddUrlConfig zddUrlConfig;
	@Autowired
	NotificationConfig notificationConfig;

	/**
	 * 专门测试用的, 使用一个通用模板
	 */
	private static final String TEMP_TEST = "BlUjsCpze1iDbeeGwTCovrAdCBa9m7eHMlUkH42Hfcw";

	/**
	 * 流程确认通知
	 */
	private static final String TEMP_PROCESS_CONFIRM = "-Sp7PhN6NBaVcvrizHd0Hz4QlVeBVt4VJmS8NKaab5I";
	/**
	 * 回款到账通知
	 */
	private static final String TEMP_IN_ACCOUNT_CHECKED = "Q_rK3doBWHoxFTp6vIEY2PSN5cWZGgvgPkxBpQ9nCt4";
	/**
	 * 业务状态变更通知
	 */
	private static final String TEMP_STATE_CHANGED = "nnSlj5AT8aBzLF5KvZK3QqiUXeWkrzCsuzmkWMvoIwc";
	/**
	 * 认证通知
	 */
	private static final String TEMP_AUTH_NOTIFY = "ySCOny8hwhu8dkG_7ZWHWZxba0T63JWavWQIbsn0jdo";
	/**
	 * 验证码通知
	 */
	private static final String TEMP_VERIFYCODE = "mFDPY6_UgFiS5fiGylS8bv5wx0Fw0wRhDaeerGhKP4A";
	/**
	 * 验证码通知
	 */
	private static final String TEMP_RECHARGE = "aqwWfk_x5cT4CC6vNhV0zKsjJUgVd1p-DZhBGsZ51M4";
	/**
	 * 公告通知
	 */
	private static final String TEMP_SEND_NOTICE = "ov7xAm6KUr22hufLpScOoOFgan1RH8OLYGBlnq7F5f4";
	/**
	 * 问卷调查公告通知
	 */
	private static final String TEMP_SURVEY_NOTICE = "vKSV5smmI5h9zd4mxRyIVyu4FMqqCQJu1MyEwso7gZs";
	/**
	 * 订单付款成功通知 订单确认成功通知
	 */
	private static final String TEMP_ORDER_TAKE_NOTICE = "YHSIUpR6Rmw91K7y0Vr9T5RwPgkjOms9bDHCZYKV2RM";

	// 用户注册审核通知
	public static final String AUTH_NOTIFY_TEMPLATE = "rfc-acIEynIHLihYsxODAhU6cpHVWyq0w1IoheepK_k";
	// 用户注册成功通知
	public static final String REGISTER_NOTIFY_TEMPLATE = "P_s2UdpLeucmaVvoGwUd3AQZQ4836suw307y0Z2Lz4o";
	// 发票开局成功通知
	public static final String INVOICE_NOTIFY_TEMPLATE = "7g8OmcbCPoOJNLTKXdZ-HduMG8qkOx7NFVF-LzJU3kU";
	// 账号注销申请结果通知
	public static final String RESCISSION_NOTIFY_TEMPLATE = "4MVmuTNoSMtYyrvoEKErANuMwp2W_eU4gulIJCAbG68";
	// 用户资料审核提醒
	public static final String INFORMATION_VERIFY_NOTIFY_TEMPLATE = "hGmCLGQsqKBiEGkD2U3IVZNHaSmacybpYj8-cgFBeJw";
	// 发票开具申请通知
	public static final String INVOICE_APPLY_NOTIFY_TEMPLATE = "R7qPk5ZjUKTnllstho1_XXdAOIyP8GOP1Vy9v1d8jP0";

	ExecutorService executor;

	public WxMessageServiceImpl() {
		this.executor = Executors.newSingleThreadExecutor();
	}

	/**
	 * 发送模板消息,如果直接在当前线程发送会堵塞当前线程,造成服务器与前端交互等待时间太长,所以这里采用线程executor,单独执行
	 *
	 * @param message
	 * @return
	 */
	private Future sendMessage(WxTempleteMessage message, String name, Integer type, String templateId, Integer userId) {
		if (type != null) {
			String first = "";
			String remark = "";
			String str = "";

			Map<String, WxTempleteMessage.ValueColor> data = message.getData();
			Iterator<Map.Entry<String, WxTempleteMessage.ValueColor>> iterator = data.entrySet().iterator();
			while (iterator.hasNext()) {
				Map.Entry<String, WxTempleteMessage.ValueColor> next = iterator.next();
				String key = next.getKey();
				if (key.equals("first")) {
					first = next.getValue().getValue();
				} else if (key.equals("remark")) {
					remark = next.getValue().getValue();
				} else {
					str += next.getValue().getValue();
				}
			}
			new WxNotice().setNoticeType(type)
					.setNoticePeople(name)
					.setNoticeTitle(first)
					.setNoticeRemarks(remark)
					.setNoticeContent(str)
					.setNoticeTemplate(templateId)
					.setUserId(userId)
					.insert();
		}
		return executor.submit(() -> {
			wxApiService.sendTempleteMessage(message);
		});

	}

	@Override
	public boolean notifyUserIncomeChecked(int projectid) {

		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) {
			return false;
		}

		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", userid));
		if (makerAccount == null) return false;
		String openid = maker.getOpenid();
/*
		{{first.DATA}}

		详细内容{{first.DATA}}
		项目名称：{{keyword1.DATA}}
		到账金额：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_IN_ACCOUNT_CHECKED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("项目到款通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(project.getProjectname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(project.getProjectPayAmount().setScale(2, RoundingMode.DOWN).toString()));
		data.put("remark", WxTempleteMessage.ValueColor.of("请注意查收,谢谢!"));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_IN_ACCOUNT_CHECKED, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean notifyUserProjectPublish(int projectid) {

		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) return false;

		Maker maker = new Maker().selectById(project.getUserid());
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		MakerStudio makerStudio = new MakerStudio().selectById(project.getUserid());
		if (makerStudio == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		String openid = maker.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		message.setUrl(String.format(commonConfig.getProjectDetailUrl(), projectid));
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first",
				WxTempleteMessage.ValueColor.of("企业-" + company.getCompname() + "发布了一个新项目给您:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("项目发布成功,请尽快完成。 "));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean notifyAdminProjectPublishError(String notifyMsg) {
		String name = "tina";
		String touser = notificationConfig.getTestNoticeOpenids().get(2);//通知tina

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(touser);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(notifyMsg));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("请尽快处理"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		message.setData(data);
		sendMessage(message, name, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		return true;
	}

	@Override
	public boolean notifyUserLongTermProjectPublish(int projectid) {
		LongTermProject project = new LongTermProject().selectById(projectid);
		Maker maker = new Maker().selectById(project.getUserid());
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		MakerStudio makerStudio = new MakerStudio().selectById(project.getUserid());
		if (makerStudio == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		String openid = maker.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first",
				WxTempleteMessage.ValueColor.of("企业-" + company.getCompname() + "发布了一个新项目给您:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("项目发布成功,请尽快完成。 "));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerAccount.getUserid());
		return true;
	}

	public boolean notifyCompanyProjectCheck(int projectid) {

		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) return false;

		MakerStudio makerStudio = new MakerStudio().selectById(project.getUserid());
		if (makerStudio == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		String openid = company.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first",
				WxTempleteMessage.ValueColor.of("创客-" + makerStudio.getUsername() + "通知您验收项目:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("创客完成项目,等待验收。"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED, companyAccount.getCompid());
		return true;
	}

	@Override
	public boolean notifyUserProjectPassed(int projectid) {

		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) return false;

		MakerStudio makerStudio = new MakerStudio().selectById(project.getUserid());
		if (makerStudio == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		String openid = maker.getOpenid();
		/*
		标题业务状态变更通知
        行业IT科技 - 互联网|电子商务
        详细内容{{first.DATA}}
        变更类型：{{keyword1.DATA}}
        变更结果：{{keyword2.DATA}}
        变更时间：{{keyword3.DATA}}
        {{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(company.getCompname() + "已经验收通过项目:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("企业验收通过"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerAccount.getUserid());
		return true;
	}

	/**
	 *  创客完成 项目，首次评价
	 *
	 * @param projectid
	 * @return
	 */
	@Override
	public boolean notifyMakerEvaluate(int projectid) {
		CompanyProject project = new CompanyProject().selectById(projectid);
		if (null == project) return false;
		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (null == maker) return false;
		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;
		Company company = new Company().selectById(project.getCompid());
		if (null == company) return false;

		String url = String.format(zddUrlConfig.getZddOneEvaluateUrl(), maker.getUserid(), UserType.MAKER, project.getCompid(),
				UserType.COMPANY, ProjectType.ZHIDUODUO);
		String openid = maker.getOpenid();
		//判断创客是否评价过，如果评价过则不发送通知
		if (0 != account.getWhetherEvaluate()) return false;
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setUrl(url);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("您好，恭喜您交易成功，平台邀请您对本次交易进行评价！", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("交易完成"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("邀请评价"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.DateToStr(DateUtil.FORMAT_STYLE_6, new Date())));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, account.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, account.getUserid());
		return true;
	}

	/**
	 *  创客完成纯代理项目，首次评价
	 *
	 * @param invoiceid
	 * @return
	 */
	@Override
	public boolean notifyMakerTaxerEvaluate(int invoiceid) {
		TaxerInvoice invoice = new TaxerInvoice().selectById(invoiceid);
		if (null == invoice) return false;
		Integer userid = invoice.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (null == maker) return false;
		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;

		String url = String.format(zddUrlConfig.getZddOneEvaluateUrl(), maker.getUserid(), UserType.MAKER, invoice.getCompanyid(),
				UserType.COMPANY, ProjectType.TAXER);
		String openid = maker.getOpenid();
		//判断创客是否评价过，如果评价过则不发送通知
		if (0 != account.getWhetherEvaluate()) return false;
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setUrl(url);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("您好，恭喜您交易成功，平台邀请您对本次交易进行评价！", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("交易完成"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("邀请评价"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.DateToStr(DateUtil.FORMAT_STYLE_6, new Date())));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, account.getRealname(), EmailType.TAXER_MAKER, TEMP_STATE_CHANGED, account.getUserid());
		return true;
	}

	@Override
	public boolean notifyMakerCrowdsourceProjectEvaluate(int projectItemId) {
		CrowdsourceProjectItem projectItem = new CrowdsourceProjectItem().selectById(projectItemId);
		if (null == projectItem) return false;
		if (!NumberUtil.equals(projectItem.getUserType(), CrowdsourceUserType.STUDIO)) {
			return false;
		}
		CrowdsourceProject crowdsourceProject = new CrowdsourceProject().selectById(projectItem.getProjectid());
		if (crowdsourceProject == null) return false;

		Maker maker = new Maker().selectById(projectItem.getUserid());
		if (null == maker) return false;
		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;

		String url = String.format(zddUrlConfig.getZddOneEvaluateUrl(), maker.getUserid(), UserType.MAKER, crowdsourceProject.getCompid(),
				UserType.COMPANY, ProjectType.CROWDSOURCE);
		String openid = maker.getOpenid();
		//判断创客是否评价过，如果评价过则不发送通知
		if (0 != account.getWhetherEvaluate()) return false;
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setUrl(url);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("您好，恭喜您交易成功，平台邀请您对本次交易进行评价！", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("交易完成"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("邀请评价"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.DateToStr(DateUtil.FORMAT_STYLE_6, new Date())));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, account.getRealname(), EmailType.CROWDSOURCE_MAKER, TEMP_STATE_CHANGED, account.getUserid());
		return true;
	}

	@Override
	public boolean notifyCrowdsourceProjectTradeItemPaid(CrowdsourceTradeRecordItem recordItem) {
		CrowdsourceProjectItem projectItem = new CrowdsourceProjectItem().selectById(recordItem.getProjectItemId());
		if (null == projectItem) return false;
		if (!NumberUtil.equals(projectItem.getUserType(), CrowdsourceUserType.STUDIO)) {
			return false;
		}
		CrowdsourceProject crowdsourceProject = new CrowdsourceProject().selectById(projectItem.getProjectid());
		if (crowdsourceProject == null) return false;

		Maker maker = new Maker().selectById(projectItem.getUserid());
		if (null == maker) return false;
		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;

		String openid = maker.getOpenid();

/*
		{{first.DATA}}

		详细内容{{first.DATA}}
		项目名称：{{keyword1.DATA}}
		到账金额：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_IN_ACCOUNT_CHECKED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("智众包项目到款通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(crowdsourceProject.getProjectName()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(recordItem.getTradeamount().setScale(2, RoundingMode.DOWN).toString()));
		data.put("remark", WxTempleteMessage.ValueColor.of("请注意查收,谢谢!"));
		message.setData(data);

		sendMessage(message, account.getRealname(), EmailType.CROWDSOURCE_MAKER, TEMP_IN_ACCOUNT_CHECKED, account.getUserid());
		return true;
	}

	@Override
	public boolean testNotifyUserEvaluate(int projectid, String url) {
		CompanyProject project = new CompanyProject().selectById(projectid);
		if (null == project) return false;
		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (null == maker) return false;
		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;
		Company company = new Company().selectById(project.getCompid());
		if (null == company) return false;
		//判断创客是否评价过，如果评价过则不发送通知
		if (0 != account.getWhetherEvaluate()) return false;
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser("oB8CR0SpZRdPAD67vRLAnuadWjus");
		message.setUrl(url);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(company.getCompname() + "已经验收通过项目:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("企业验收通过"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("项目验收完成请完成评价"));
		message.setData(data);
		sendMessage(message, "tina", EmailType.OTHER, TEMP_STATE_CHANGED, null);
		return true;
	}

	@Override
	public boolean notifyCustomerService(String info) {

		String touser = "oB8CR0YV1yqr2VTm-CIAGbo2lC_E";// 通知judy
		String name = "judy";
		if (!ContextUtil.isProd()) {
			touser = notificationConfig.getTestNoticeOpenids().get(2);//通知tina
			name = "tina";
		}
		//        Maker maker = new Maker().selectById(userid);
		//        if (null == maker || StringUtils.isBlank(maker.getOpenid())) return false;
		/*
		标题认证通知
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(touser);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(info, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("评价更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("已完成评价"));
		message.setData(data);
		sendMessage(message, name, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		return true;
	}

	@Override
	public void tradeNetErrorNotifyAdmin() {

		String name = "tina";
		String touser = notificationConfig.getTestNoticeOpenids().get(2);//通知tina
		/*
		标题认证通知
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(touser);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("请求招行接口异常"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("请检查网络"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		message.setData(data);
		sendMessage(message, name, EmailType.OTHER, TEMP_STATE_CHANGED, null);
	}

	@Override
	public boolean notifyUserCompanyProjectArbitrate(int projectid) {
		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		//发送给创客
		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		String openid = maker.getOpenid();

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(project.getProjectname() + "已经通过智多平台仲裁!", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2",
				WxTempleteMessage.ValueColor.of("平台仲裁金额为" + project.getProjectdealamount().setScale(2, RoundingMode.DOWN).toString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerAccount.getUserid());

		//--------发送给企业-------

		String openidComp = company.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage messageComp = new WxTempleteMessage();
		messageComp.setTouser(openidComp);
		messageComp.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> dataComp = new HashMap<>();
		dataComp.put("first", WxTempleteMessage.ValueColor.of(project.getProjectname() + "已经通过智多平台仲裁!", "#000000"));
		dataComp.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		dataComp.put("keyword2",
				WxTempleteMessage.ValueColor.of("平台仲裁金额为" + project.getProjectdealamount().setScale(2, RoundingMode.DOWN).toString()));
		dataComp.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		dataComp.put("remark", WxTempleteMessage.ValueColor.of(""));
		messageComp.setData(dataComp);

		sendMessage(messageComp, company.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED, company.getCompid());
		return true;
	}

	@Override
	public boolean notifyAdminPaymentFail(TradeRecord trade) {

		CompanyProject project = new CompanyProject().selectById(trade.getProjectid());
		if (project == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		MakerDetailDto studio = makerMapper.getUserDetail(project.getUserid());
		if (studio == null) return false;

		//通知给指定的人, 包括 操作人员, 开发人员
		Map<String, String> payFailedNotifyOpenids = payConfig.getPayFailedNotifyOpenids();


		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(
				"项目款代付交易失败通知！" + "\n企业名：" + company.getCompname() + "\n创客名：" + studio.getUsername() + "\n项目名：" + project.getProjectname() +
						"\n交易编号：" + trade.getTradeno() + "\n交易金额：" + trade.getTradeamount(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of((trade.getTradestate() == 4 ? "交易失败" : "交易拒绝")));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("ErrorCode=" + trade.getErrorcode() + " ,ErrorMsg=" + trade.getErrormsg()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(trade.getFinishtime(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		//        openids.stream().map(openid -> {
		//            WxTempleteMessage msg = new WxTempleteMessage();
		//            BeanUtils.copyProperties(message, msg);
		//            msg.setTouser(openid);
		//            return msg;
		//        }).forEach(this::sendMessage);
		//通知管理人员
		Set<String> strings = payFailedNotifyOpenids.keySet();
		Iterator<String> iterator = strings.iterator();
		while (iterator.hasNext()) {
			String next = iterator.next();
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(payFailedNotifyOpenids.get(next));
			sendMessage(msg, next, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}

		//通知创客
		if(!trade.getErrormsg().contains("账户透支") || !trade.getErrormsg().contains("余额不足")){
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(studio.getOpenid());
			sendMessage(msg, studio.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, studio.getUserid());
		}

		return true;
	}

	@Override
	public boolean notifyAdminPaymentFailNoMaker(TradeRecord trade) {
		CompanyProject project = new CompanyProject().selectById(trade.getProjectid());
		if (project == null) return false;
		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;
		MakerDetailDto studio = makerMapper.getUserDetail(project.getUserid());
		if (studio == null) return false;
		//通知给指定的人, 包括 操作人员, 开发人员
		Map<String, String> payFailedNotifyOpenids = payConfig.getPayFailedNotifyOpenids();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(
				"项目款代付交易失败通知！" + "\n企业名：" + company.getCompname() + "\n创客名：" + studio.getUsername() + "\n项目名：" + project.getProjectname() +
						"\n交易编号：" + trade.getTradeno() + "\n交易金额：" + trade.getTradeamount(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of((trade.getTradestate() == 4 ? "交易失败" : "交易拒绝")));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("ErrorCode=" + trade.getErrorcode() + " ,ErrorMsg=" + trade.getErrormsg()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(trade.getFinishtime(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		//        openids.stream().map(openid -> {
		//            WxTempleteMessage msg = new WxTempleteMessage();
		//            BeanUtils.copyProperties(message, msg);
		//            msg.setTouser(openid);
		//            return msg;
		//        }).forEach(this::sendMessage);
		Set<String> strings = payFailedNotifyOpenids.keySet();
		Iterator<String> iterator = strings.iterator();
		while (iterator.hasNext()) {
			String next = iterator.next();
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(payFailedNotifyOpenids.get(next));
			sendMessage(msg, next, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}
		return true;
	}

	@Override
	public boolean notifyCompanyRecharged(int rechargeid) {

		CompanyRecharge recharge = new CompanyRecharge().selectById(rechargeid);
		if (recharge == null) return false;

		Company company = new Company().selectById(recharge.getCompid());
		if (company == null) return false;
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		String openid = company.getOpenid();
/*
		详细内容
		{{first.DATA}}
		会员账号：{{keyword1.DATA}}  这里可以显示公司名字
		充值金额：{{keyword2.DATA}}
		充值订单：{{keyword3.DATA}}  这里可以显示回单唯一ID
		充值时间：{{keyword4.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_RECHARGE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("充值入账成功通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(company.getCompname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(recharge.getAmount().setScale(2, RoundingMode.DOWN).toString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(recharge.getReceiptno()));
		data.put("keyword4", WxTempleteMessage.ValueColor.of(DateUtil.getString(recharge.getRechargetime(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of("请注意核对,谢谢!"));
		message.setData(data);

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_RECHARGE, company.getCompid());
		return true;
	}

	@Override
	public boolean notifyCompanyZhaoShangSubLedgerRecharged(CompanyZhaoshangSubLedgerRecharge recharge) {

		if (recharge == null) return false;

		Company company = new Company().selectById(recharge.getCompid());
		if (company == null) return false;
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		String openid = company.getOpenid();
/*
		详细内容
		{{first.DATA}}
		会员账号：{{keyword1.DATA}}  这里可以显示公司名字
		充值金额：{{keyword2.DATA}}
		充值订单：{{keyword3.DATA}}  这里可以显示回单唯一ID
		充值时间：{{keyword4.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_RECHARGE);
		message.putData("first", "充值入账成功通知");
		message.putData("keyword1", company.getCompname());
		message.putData("keyword2", recharge.getAmount().setScale(2, RoundingMode.DOWN).toString());
		message.putData("keyword3", recharge.getOrderNo());
		message.putData("keyword4", DateUtil.getString(recharge.getFinishtime(), DateUtil.FORMAT_STYLE_6));
		message.putData("remark", "请注意核对,谢谢!");

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_RECHARGE, company.getCompid());
		return true;
	}

	@Override
	public boolean notifyCashierCompanyZhaoShangSubLedgerRecharged(CompanyZhaoshangSubLedgerRecharge recharge) {

		if (recharge == null) return false;
		Company company = new Company().selectById(recharge.getCompid());
		if (company == null) return false;
		PaymentMerchant paymentMerchant = new PaymentMerchant().selectById(recharge.getMerchantId());
		if (paymentMerchant == null) return false;

		String openid = notificationConfig.getCashierCompanyZhaoShangLedgerRecharge();
/*
		详细内容
		{{first.DATA}}
		会员账号：{{keyword1.DATA}}  这里可以显示公司名字
		充值金额：{{keyword2.DATA}}
		充值订单：{{keyword3.DATA}}  这里可以显示回单唯一ID
		充值时间：{{keyword4.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_RECHARGE);
		message.putData("first", "企业的招商银行记账子单元充值入账成功通知");
		message.putData("keyword1", "企业名称：" + company.getCompname() + ", 支付主体：" + paymentMerchant.getName());
		message.putData("keyword2", recharge.getAmount().setScale(2, RoundingMode.DOWN).toString());
		message.putData("keyword3", recharge.getOrderNo());
		message.putData("keyword4", DateUtil.getString(recharge.getFinishtime(), DateUtil.FORMAT_STYLE_6));
		message.putData("remark", "请注意核对,谢谢!");

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_RECHARGE, company.getCompid());
		return true;
	}

	@Override
	public boolean notifyCashierCompanyZhaoShangSubLedgerIncomingRecordSensitive(CompanyZhaoshangSubLedgerIncomingRecord record) {

		if (record == null) return false;
		Company company = new Company().selectById(record.getCompid());
		if (company == null) return false;
		PaymentMerchant paymentMerchant = new PaymentMerchant().selectById(record.getMerchantId());
		if (paymentMerchant == null) return false;

		String openid = notificationConfig.getCashierCompanyZhaoShangLedgerIncomingRecordSensitive();
/*
		详细内容
		{{first.DATA}}
		会员账号：{{keyword1.DATA}}  这里可以显示公司名字
		充值金额：{{keyword2.DATA}}
		充值订单：{{keyword3.DATA}}  这里可以显示回单唯一ID
		充值时间：{{keyword4.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_RECHARGE);
		message.putData("first", "企业的招商银行记账子单元转账充值记录包含敏感词");
		message.putData("keyword1", "企业名称：" + company.getCompname() + ", 支付主体：" + paymentMerchant.getName());
		message.putData("keyword2", record.getTrxamt());
		message.putData("keyword3", record.getTrxnbr());
		message.putData("keyword4", DateUtil.getString(record.getTrxdate(), DateUtil.FORMAT_STYLE_2) + " " + record.getTrxtim());
		message.putData("remark", "请手动操作该笔转账。");

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_RECHARGE, company.getCompid());
		return true;
	}

	@Override
	public boolean notifyCompanyApplyRecharge(String compname) {

		//        String result = "企业：" + compname + "已申请账户充值";
		//        String remark = "请尽快处理";
		//        //
		//        String openid = "oB8CR0Y8d_AK9BFtDW0vvzdJjTNw";
		//        WxTempleteMessage message = new WxTempleteMessage();
		//        message.setTouser(openid);
		//        message.setTemplate_id(TEMP_SEND_NOTICE);
		//        Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		//        data.put("first", WxTempleteMessage.ValueColor.of("企业充值账户申请通知", "#000000"));
		//        data.put("keyword1", WxTempleteMessage.ValueColor.of("企业名-" + compname));
		//        data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		//        data.put("keyword3", WxTempleteMessage.ValueColor.of(result));
		//        data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		//        message.setData(data);
		//
		//        sendMessage(message);
		return true;
	}

	@Override
	public boolean notifyCompanyOfflineRecharged(CompanyOfflineRechargeDetail rechargeDetail) {
		if (rechargeDetail == null) return false;
		CompanyOfflineRecharge recharge = new CompanyOfflineRecharge().selectById(rechargeDetail.getOfflineRechargeId());

		Company company = new Company().selectById(recharge.getCompid());
		if (company == null) return false;
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		String openid = company.getOpenid();
/*
		详细内容
		{{first.DATA}}
		会员账号：{{keyword1.DATA}}  这里可以显示公司名字
		充值金额：{{keyword2.DATA}}
		充值订单：{{keyword3.DATA}}
		充值时间：{{keyword4.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_RECHARGE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("充值入账成功通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(company.getCompname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(rechargeDetail.getAmount().setScale(2, RoundingMode.DOWN).toString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(rechargeDetail.getOfflineRechargeNo()));
		data.put("keyword4",
				WxTempleteMessage.ValueColor.of(DateUtil.getString(rechargeDetail.getRechargeTime(), DateUtil.FORMAT_STYLE_1)));
		data.put("remark", WxTempleteMessage.ValueColor.of("请注意核对,谢谢!"));
		message.setData(data);

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_RECHARGE, company.getCompid());
		return true;
	}

	@Override
	public boolean userAuthState(int acctid) {

		MakerAccount makerAccount = new MakerAccount().selectById(acctid);
		if (makerAccount == null) return false;

		Maker maker = new Maker().selectById(makerAccount.getUserid());
		if (maker == null) return false;

		MakerAuthRecord record = new MakerAuthRecord().selectOne(
				Condition.create().eq("acctid", acctid).orderBy("id", false).last("limit 1"));

		String authResult;
		String remark = "";
		switch (record.getState()) {
			case 1:
				authResult = "审核失败,原因-" + record.getReason();
				remark = "请重新提交审核资料,谢谢";
				break;
			case 0:
				authResult = "审核通过!";
				// 准创客特殊消息:
				if (makerAccount.getTemporaryLogin() == Constants.TRUE) {
					remark = "您的实名信息已通过审核，请点击详情上传电子签名，谢谢！";
				}
				break;
			default:
				authResult = "";

		}

		String openid = maker.getOpenid();
/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(AUTH_NOTIFY_TEMPLATE);

		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("用户注册审核通知", "#000000"));
		data.put("thing2", WxTempleteMessage.ValueColor.of(makerAccount.getRealname()));
		data.put("time5", WxTempleteMessage.ValueColor.of(DateUtil.getString(maker.getCreatetime())));
		data.put("const4", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, AUTH_NOTIFY_TEMPLATE, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean notifyMakerEntrustTaxVideoRejected(MakerStudio makerStudio) {
		Maker maker = new Maker().selectById(makerStudio.getUserid());
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", makerStudio.getUserid()));
		if (makerAccount == null) return false;

		String authResult;
		String remark = "";
		if (NumberUtil.equals(makerStudio.getEntrustTaxVideoState(), MakerEntrustTaxVideoState.REJECTED)) {
			authResult = "审核失败,原因-" + makerStudio.getEntrustTaxVideoRemark();
			remark = "请重新提交审核资料,谢谢";
		} else {
			return false;
		}

		String openid = maker.getOpenid();
/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("创客委托定税视频认证审核通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("创客名-" + makerAccount.getRealname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(authResult));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_AUTH_NOTIFY, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean userStudioConfirmed(int userid) {

		MakerStudio makerStudio = new MakerStudio().selectById(userid);
		if (makerStudio == null) return false;

		Maker maker = new Maker().selectById(makerStudio.getUserid());
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		String openid = maker.getOpenid();
/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("创客工作室开户结果通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("工作室名-" + makerStudio.getUsername()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("开户成功"));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_AUTH_NOTIFY, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean compAuthState(int compid) {

		Company company = new Company().selectById(compid);
		if (company == null) return false;
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		CompanyAuthRecord record = new CompanyAuthRecord().selectOne(
				Condition.create().eq("compid", compid).orderBy("id", false).last("limit 1"));

		String authResult;
		String remark = "";
		switch (record.getState()) {
			case 1:
				authResult = "审核失败,原因-" + record.getReason();
				remark = "请重新提交审核资料,谢谢";
				break;
			case 0:
				authResult = "审核通过!";
				break;
			default:
				authResult = "";

		}

		String openid = company.getOpenid();
/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("企业实名认证审核通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("企业名-" + company.getCompname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(authResult));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_AUTH_NOTIFY, company.getCompid());

		if (record.getState() == 0) {
			//审核通过，通知胡刚
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(notificationConfig.getBossOpenid());
			sendMessage(msg, "胡刚", EmailType.OTHER, TEMP_AUTH_NOTIFY, null);
		}
		return true;
	}

	public boolean sendVerifycode(int rechargeid, String verifycode) {

		CompanyRechargeDto recharge = companyRechargeMapper.getRechargeDetail(rechargeid);
		if (recharge == null) return false;

		//充值接口发送验证码的openid改成“刘晓语”的：oB8CR0QLQBed9zjqV7Evcvq5PZx8
		String openid = "oB8CR0QLQBed9zjqV7Evcvq5PZx8";
/*
		标题验证码通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		验证码：{{keyword1.DATA}}
		通知时间：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_VERIFYCODE);
		message.setUrl(rechargeNotifyConfig.getDetailurl() + rechargeid);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(recharge.getCompname() + " 充值确认验证码", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(verifycode));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of("验证码在十分钟内有效"));
		message.setData(data);

		sendMessage(message, "管理员", EmailType.OTHER, TEMP_VERIFYCODE, null);
		return true;
	}

	@Override
	public boolean sendOfflineVerifycode(int rechargeid, String verifycode) {
		CompanyOfflineRechargeDetailDto recharge = companyOfflineRechargeDetailMapper.getRechargeDetail(rechargeid);
		if (recharge == null) return false;

		String openid = rechargeNotifyConfig.getOpenid();
/*
		标题验证码通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		验证码：{{keyword1.DATA}}
		通知时间：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_VERIFYCODE);
		message.setUrl(rechargeNotifyConfig.getDetailurl() + rechargeid);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(recharge.getCompname() + " 充值确认验证码", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(verifycode));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of("验证码在十分钟内有效"));
		message.setData(data);

		sendMessage(message, "管理员", EmailType.OTHER, TEMP_VERIFYCODE, null);
		return true;
	}

	@Override
	public boolean sendNotice(String title, String url, String openid) {

		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		message.setUrl(url);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 平台公告", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(title));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of("请点击查看详情"));
		message.setData(data);

		sendMessage(message, null, null, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean sendInvoiceNotice(int invoiceid, int toType) {

		Invoice invoice = new Invoice().selectById(invoiceid);
		if (invoice == null) return false;

		Maker maker = new Maker().selectById(invoice.getUserid());
		Company company = new Company().selectById(invoice.getCompid());
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		if (maker == null) return false;
		if (company == null) return false;

		MakerStudio makerStudio = new MakerStudio().selectById(invoice.getUserid());

		String openid;
		String title;
		String invoiceName;
		String keyword3;
		if (invoice.getInvoicetype() == 1) {
			invoiceName = "电子普票";
			keyword3 = "电子普票已发送至" + invoice.getEmail();
		} else if (invoice.getInvoicetype() == 2) {
			invoiceName = "纸质专票";
			keyword3 = "纸质发票已寄出，快递信息为：" + invoice.getExpress() + "," + invoice.getExpressno();
		} else {
			return false;
		}
		String keyword1 = "【项目名称】" + invoice.getProjectname() + "\n【发票内容】" + invoice.getContent() + "\n【金额】" +
				NumberUtil.formatFloat2_0(invoice.getInvoiceAmount().floatValue()) + "元";
        	/*
		XX创客工作室已成功为您开具电子普票/纸质专票，具体明细如下：
		{{first.DATA}}
		系统名称：【票种】服务费?/咨询费？【金额】XX元【项目名称】？？{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：【邮箱】已发送至XXXX  {{keyword3.DATA}}
		感谢您使用 平台，期待为您的再次服务
		如有疑问，您可致电我们的全国客服电话：17710090008   {{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();

		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();

		data.put("keyword1", WxTempleteMessage.ValueColor.of(keyword1));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(keyword3));
		data.put("remark", WxTempleteMessage.ValueColor.of("如有疑问，您可致电平台全国客服电话：17710090008 "));
		message.setData(data);
		if (toType == 1) {
			openid = maker.getOpenid();
			title = "您已成功为" + company.getCompname() + "开具" + invoiceName + "，具体明细如下：";
			data.put("first", WxTempleteMessage.ValueColor.of(title, "#000000"));
			message.setTouser(openid);
			sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_SEND_NOTICE, maker.getUserid());
		} else if (toType == 2) {
			openid = company.getOpenid();
			title = makerStudio.getUsername() + "已成功为您开具" + invoiceName + "，具体明细如下：";
			data.put("first", WxTempleteMessage.ValueColor.of(title, "#000000"));
			message.setTouser(openid);
			sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_SEND_NOTICE, company.getCompid());
		} else {
			return false;
		}
		return true;
	}

	/**
	 * 纯代理发票开票成功
	 *
	 * @param invoiceid
	 * @return
	 */
	@Override
	public boolean sendTaxerInvoiceNotice(int invoiceid) {

		TaxerInvoice invoice = new TaxerInvoice().selectById(invoiceid);
		if (invoice == null) return false;

		Maker maker = new Maker().selectById(invoice.getUserid());
		if (maker == null) return false;

		MakerAccount account = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (null == account) return false;
		MakerStudio makerStudio = new MakerStudio().selectById(invoice.getUserid());
		if (makerStudio == null) return false;
		if (makerStudio.getTaxer() != 1) return false;

		String openid = maker.getOpenid();
		String title;
		String invoiceType;
		if (invoice.getInvoiceType() == 1) {
			invoiceType = "电子普票";
		} else if (invoice.getInvoiceType() == 2) {
			invoiceType = "纸质专票";
		} else {
			return false;
		}

		title = "您申请的发票已开具成功，具体明细如下：";
		String keyword1 =
				"【票种】" + invoiceType + "\n【项目名称】" + invoice.getProjectname() + "\n【发票内容】" + invoice.getInvoiceContent() + "\n【金额】" +
						NumberUtil.formatFloat2_0(invoice.getAmount().floatValue()) + "元";
		String keyword3 = "\n【邮箱】已发送至" + invoice.getInvoiceEmail();

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(title, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(keyword1));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(keyword3));
		data.put("remark", WxTempleteMessage.ValueColor.of("如有疑问，您可致电平台全国客服电话：17710090008 "));
		message.setData(data);
		message.setData(data);

		sendMessage(message, account.getRealname(), EmailType.TAXER_MAKER, TEMP_SEND_NOTICE, account.getUserid());
		return true;
	}

	@Override
	public boolean notifyUserProjectRefused(int projectid) {

		CompanyProject project = new CompanyProject().selectById(projectid);
		if (project == null) return false;

		Company company = new Company().selectById(project.getCompid());
		if (company == null) return false;

		Integer userid = project.getUserid();
		Maker maker = new Maker().selectById(userid);
		if (maker == null) return false;
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		String openid = maker.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(company.getCompname() + "拒绝验收项目:" + project.getProjectname(), "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("企业拒绝验收,\n原因:" + project.getRejectReason()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerAccount.getUserid());
		return true;
	}

	@Override
	public boolean notifyCustomerAgents(int id) {
		MakerAccount account = new MakerAccount().selectById(id);
		if (account == null) return false;

		// Phoenix + tina夏伦聪 + 汤圆tangYuan
		Map<String,String> openids = new HashMap<>();
		openids.put("oc7pF6aVMVwSo8TOsnIiePWo5cj4","Phoenix");
		openids.put("oc7pF6Wu-wu91sASP5Mjqw1xuCZY","夏伦聪");
		openids.put("oc7pF6bEs2OMcON24c9njUGOfeb4","汤圆");
		openids.put("oc7pF6SUjKLYDsCX9dWVqrxd0jeY","ruby");

		for (String openid:openids.keySet()) {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(INFORMATION_VERIFY_NOTIFY_TEMPLATE);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("用户资料审核提醒", "#000000"));
			data.put("thing1", WxTempleteMessage.ValueColor.of(account.getRealname()));
			data.put("time2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_3)));
			message.setData(data);
			sendMessage(message, openids.get(openid), EmailType.OTHER, INFORMATION_VERIFY_NOTIFY_TEMPLATE, null);
		}
		return true;
	}

	@Override
	public boolean notifyCompanyAgents(int id) {

		String name;
		Company company = new Company().selectById(id);
		if (company == null) return false;

		name = "企业 - " + company.getCompname();


		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(notificationConfig.getZhouyuchen());
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("实名认证资料提交通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(name));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("资料提交，等待审核"));
		data.put("remark", WxTempleteMessage.ValueColor.of("请尽快审核，谢谢！"));
		message.setData(data);

		sendMessage(message, "赵菲", EmailType.OTHER, TEMP_AUTH_NOTIFY, null);

		return true;
	}

	@Override
	public boolean notifyCompanyZhixiaoduo(int id) {

		OrderProduct order = new OrderProduct().selectById(id);
		if (order == null) return false;

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		//企业的通知，只发给赵菲
		notificationConfig.getCompanyAgents().forEach(openid -> {
			message.setTouser(openid);
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first",
					WxTempleteMessage.ValueColor.of("客户订购智小多订单,请及时确认。", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of("客户订购智小多订单请及时确认。"));
			data.put("keyword2", WxTempleteMessage.ValueColor.of("客户订购智小多订单,请及时确认。 "));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
			data.put("remark", WxTempleteMessage.ValueColor.of(""));
			message.setData(data);

			sendMessage(message, "赵菲", EmailType.OTHER, TEMP_AUTH_NOTIFY, null);
		});
		return true;
	}

	@Override
	public boolean notifyTakeOrder(int id) {
		OrderProduct order = new OrderProduct().selectById(id);
		Integer userid = order.getUserid();

		Maker maker = new Maker().selectById(userid);
		if (maker == null) return false;

		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", userid));
		if (makerAccount == null) return false;

		String openid = maker.getOpenid();
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first",
				WxTempleteMessage.ValueColor.of("智小多开通成功", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("智小多开通成功。"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("智小多开通成功。"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, userid);
		return true;
	}

	@Override
	public boolean notifyCompanyMakerOpenTax(Company company, MakerDetailDto userDetail) {
		String openid = company.getOpenid();
		String info = String.format("您好，%s创客的工作室，工商部门已审核通过，工作室名称为【%s】，已经完成税户办理，可以进行打款和开具发票。", userDetail.getRealname(),
				userDetail.getUsername());
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("工商审核通过", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("【工商审核通过】"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(info));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED, company.getCompid());
		return true;
	}

	@Override
	public boolean sendPerformanceNotice(PartnerDetailDto partner, int type) {

		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/

		String remark = "";
		String realname = partner.getRealname();
		switch (type) {
			case 1: //上个月
				break;
			case 2: //过去2个月
				remark = "过去两个月，合伙人-" + realname + "成功推荐客户0个";
				break;

			case 3: //过去3个月
				remark = "过去一个季度，合伙人-" + realname + "成功推荐客户0个";
				break;
			default:

				break;
		}

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(notificationConfig.getBossOpenid());
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 平台季度业绩公告", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(realname));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(partner.getEffectivedate(), DateUtil.FORMAT_STYLE_2)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of("季度业绩不良"));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, "胡刚", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean sendSurveyNotice(String title, String content, String url, String openid) {
		/*

		模版ID：vKSV5smmI5h9zd4mxRyIVyu4FMqqCQJu1MyEwso7gZs
				开发者调用模版消息接口时需提供模版ID
		标题问卷接收成功通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		问卷主题：{{keyword1.DATA}}
		发起时间：{{keyword2.DATA}}
		结束时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SURVEY_NOTICE);
		message.setUrl(url);

		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(title, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(content));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date())));
		data.put("keyword3", WxTempleteMessage.ValueColor.of("无"));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, null, null, TEMP_SURVEY_NOTICE, null);
		return true;
	}

	@Override
	public boolean sendComplaintNotice(Complaint complaint) {
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/

		String realname = complaint.getUsername();

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(notificationConfig.getBossOpenid());
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("投诉通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(realname));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(complaint.getCreatetime(), DateUtil.FORMAT_STYLE_1)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(complaint.getTitle()));
		data.put("remark", WxTempleteMessage.ValueColor.of(complaint.getContent()));
		message.setData(data);

		sendMessage(message, "胡刚", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean notifyCrowdsourcePayFailed(CrowdsourceTradeRecordItem recordItem) {

		CrowdsourceProject project = new CrowdsourceProject().selectById(recordItem.getProjectid());
		CrowdsourceProjectItem projectItem = new CrowdsourceProjectItem().selectById(recordItem.getProjectItemId());
		if (project == null) return false;

		String realname = projectItem.getRealname();
		String companyName = project.getCompname();

		//通知给指定的人
		Map<String, String> payFailedNotifyOpenids = payConfig.getPayFailedNotifyOpenids();

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(
				"智众包项目款代付交易失败通知！" + "\n企业名：" + companyName + "\n众包人员姓名：" + realname + "\n项目名：" +
						project.getProjectName() + "\n交易编号：" + recordItem.getTradeNo() + "\n交易金额：" + recordItem.getTradeamount(),
				"#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of((recordItem.getStatus() == 4 ? "交易拒绝" : "交易失败")));
		data.put("keyword2",
				WxTempleteMessage.ValueColor.of("ErrorCode=" + recordItem.getErrorCode() + " ,ErrorMsg=" + recordItem.getErrorMsg()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(recordItem.getFinishtime(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		Set<String> strings = payFailedNotifyOpenids.keySet();
		Iterator<String> iterator = strings.iterator();
		while (iterator.hasNext()) {
			String next = iterator.next();
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(payFailedNotifyOpenids.get(next));
			sendMessage(msg, next, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}
		return true;
	}

	@Override
	public boolean nofityMakerRescissionApply(MakerRescissionApply apply) {

		MakerDetailDto maker = makerMapper.getUserDetail(apply.getUserid());
		if (maker == null) return false;

		String result = "";
		String remark = "";
		Integer state = apply.getState();
		if (state == 2) {
			result = "已受理";
			remark = "注销申请已受理";
		} else if (state == 3) {
			result = "已拒绝";
			//拒绝的原因，让创客了解不通过的原因是什么
			remark = apply.getRemark();
		} else if (state == 4) {
			result = "已完成";
			remark = "注销已完成";
		}
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(maker.getTaxerOpenid());
		message.setTemplate_id(RESCISSION_NOTIFY_TEMPLATE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("账号注销申请结果通知", "#000000"));
		data.put("thing2", WxTempleteMessage.ValueColor.of("工作室名-" + maker.getUsername()));
		data.put("phrase8", WxTempleteMessage.ValueColor.of(result));
		data.put("phrase11", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, maker.getRealname(), EmailType.TAXER_MAKER, RESCISSION_NOTIFY_TEMPLATE, maker.getUserid());
		return true;
	}

	@Override
	public boolean notifyBusinessAuthenticationFailed(String name, String openid, String reason, Integer userId) {
		/*
			标题认证通知
			行业IT科技 - 互联网|电子商务
			详细内容{{first.DATA}}
			认证详情：{{keyword1.DATA}}
			认证结果：{{keyword2.DATA}}
			{{remark.DATA}}
			*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("身份验证审核通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("创客名-" + name));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("失败，原因-" + reason));
		data.put("remark", WxTempleteMessage.ValueColor.of("请重新上传工商登记注册身份验证完成截图，谢谢。"));
		message.setData(data);

		sendMessage(message, name, EmailType.MAKER, TEMP_AUTH_NOTIFY, userId);
		return true;
	}

	@Override
	public boolean notifyJiugeOfflineProjectPaying(CompanyProject project) {

		MakerDetailDto maker = makerMapper.getUserDetail(project.getUserid());
		if (maker == null) return false;
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String payAmount = project.getProjectPayAmount().setScale(2, RoundingMode.DOWN).toString();
		String result = "应付金额" + payAmount + "元";
		String remark = "请尽快处理";
		// Cindy,天津市南开区李含创客企业管理咨询工作室
		String openid = "oB8CR0Y8d_AK9BFtDW0vvzdJjTNw";
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("创客项目平台线下支付通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("工作室名-" + maker.getUsername()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(result));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, "Cindy", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean notifyCompanyTransferMakerGroupon(CompanyTransferMakerGroupon companyTransferMakerGroupon) {

		Company company = new Company().selectById(companyTransferMakerGroupon.getCompid());
		if (company == null) return false;
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String payAmount = companyTransferMakerGroupon.getAmount().setScale(2, RoundingMode.DOWN).toString();
		String result = "申请转账金额" + payAmount + "元";
		String remark = "请尽快处理";
		// Cindy,天津市南开区李含创客企业管理咨询工作室
		String openid = "oB8CR0Y8d_AK9BFtDW0vvzdJjTNw";
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("企业申请划款到支付宝，请尽快处理", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("企业名-" + company.getCompname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(result));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, "Cindy", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean notifyPartnerWithdrawFail(PartnerWithdraw withdraw) {

		Partner partner = new Partner().selectById(withdraw.getPartnerid());
		if (partner == null) return false;

		PartnerAccount partnerAccount = new PartnerAccount().selectOne(Condition.create().eq("partnerid", withdraw.getPartnerid()));

		//通知给指定的人
		Map<String, String> payFailedNotifyOpenids = payConfig.getPayFailedNotifyOpenids();
		payFailedNotifyOpenids.put("纪锦娟", notificationConfig.getFinanceList().get(1));


		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(
				"合伙人提现失败通知！" + "\n合伙人：" + partnerAccount.getRealname() + "\n提现编号：" + withdraw.getWdno() + "\n提现金额：" + withdraw.getAmount(),
				"#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of((withdraw.getState() == 4 ? "交易失败" : "交易拒绝")));
		data.put("keyword2",
				WxTempleteMessage.ValueColor.of("ErrorCode=" + withdraw.getErrorcode() + " ,ErrorMsg=" + withdraw.getErrormsg()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(withdraw.getFinishtime(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		//
		//        openids.stream().map(openid -> {
		//            WxTempleteMessage msg = new WxTempleteMessage();
		//            BeanUtils.copyProperties(message, msg);
		//            msg.setTouser(openid);
		//            return msg;
		//        }).forEach(this::sendMessage);
		Set<String> strings = payFailedNotifyOpenids.keySet();
		Iterator<String> iterator = strings.iterator();
		while (iterator.hasNext()) {
			String next = iterator.next();
			WxTempleteMessage msg = new WxTempleteMessage();
			BeanUtils.copyProperties(message, msg);
			msg.setTouser(payFailedNotifyOpenids.get(next));
			sendMessage(msg, next, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}
		//通知合伙人
		WxTempleteMessage msg = new WxTempleteMessage();
		BeanUtils.copyProperties(message, msg);
		msg.setTouser(partner.getOpenid());
		sendMessage(msg, partnerAccount.getRealname(), EmailType.PARTNER, TEMP_STATE_CHANGED, partnerAccount.getPartnerid());

		return true;
	}

	@Override
	public boolean sendPartnerStudioWithdrawNotice(PartnerAccount account, PartnerStudioWithdraw zhiduoduoWithdraw,
	                                               PartnerStudioWithdraw crowdsourceWithdraw) {

		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String zhiduoduoAmount = "0";
		String crowdsourceAmount = "0";
		if (zhiduoduoWithdraw != null) zhiduoduoAmount = zhiduoduoWithdraw.getAmount().toString();
		if (crowdsourceWithdraw != null) crowdsourceAmount = crowdsourceWithdraw.getAmount().toString();

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(notificationConfig.getBossOpenid());
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("合伙人发起了工作室模式提现", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(
				String.format("合伙人-%1$s，本次提现 佣金：%2$s元，智众包佣金：%3$s元", account.getRealname(), zhiduoduoAmount, crowdsourceAmount)));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of("请尽快处理"));
		message.setData(data);

		sendMessage(message, "胡刚", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean notifyCustomerAgentGongQingMakerDetectionFailure(MakerAccount account, String msg) {
		if (account == null) return false;
		Maker maker = new Maker().selectById(account.getUserid());
		String detail = "共青城创客 - " + account.getRealname();
		ArrayList<String> list = Lists.newArrayList(notificationConfig.getCustomerAgents().get(0), notificationConfig.getBossOpenid(),
				notificationConfig.getTestNoticeOpenids().get(2));
		Map<String, String> peopleName = new HashMap<>();
		peopleName.put(notificationConfig.getCustomerAgents().get(0), "赵菲");
		peopleName.put(notificationConfig.getBossOpenid(), "胡刚");
		peopleName.put(notificationConfig.getTestNoticeOpenids().get(2), "tina");
		list.forEach(openid -> {
			/*
			标题认证通知
			行业IT科技 - 互联网|电子商务
			详细内容{{first.DATA}}
			认证详情：{{keyword1.DATA}}
			认证结果：{{keyword2.DATA}}
			{{remark.DATA}}
			*/
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_AUTH_NOTIFY);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("共青城创客活体检测失败通知", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of(detail));
			data.put("keyword2", WxTempleteMessage.ValueColor.of(msg));
			data.put("remark", WxTempleteMessage.ValueColor.of("请及时处理"));
			message.setData(data);

			sendMessage(message, peopleName.get(openid), EmailType.OTHER, TEMP_AUTH_NOTIFY, null);
		});
		return true;
	}

	@Override
	public boolean balanceInsufficientNotice(String info, int type) {
		System.out.println("预警通知");
		if (StringUtil.isEmpty(info)) {
			return false;
		}
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		ArrayList<String> list = null;
		Map<String, String> peopleName = new HashMap<>();
		if (type == 1) {
			list = Lists.newArrayList(notificationConfig.getFinanceList().get(0));
			peopleName.put(notificationConfig.getFinanceList().get(0), "纪锦娟");
		} else {
			list = Lists.newArrayList(notificationConfig.getBossOpenid(), notificationConfig.getTestNoticeOpenids().get(2));
			peopleName.put(notificationConfig.getBossOpenid(), "胡刚");
			peopleName.put(notificationConfig.getTestNoticeOpenids().get(2), "tina");
		}

		list.forEach(openid -> {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("账号余额低于100万预警", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of(info));
			data.put("keyword2", WxTempleteMessage.ValueColor.of("请尽快充值"));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
			data.put("remark", WxTempleteMessage.ValueColor.of(""));
			message.setData(data);
			sendMessage(message, peopleName.get(openid), EmailType.OTHER, TEMP_STATE_CHANGED, null);
		});
		return true;
	}

	@Override
	public boolean examineMakerToBusinessInfoNotify(int acctid, int flag) {
		MakerAccount makerAccount = new MakerAccount().selectById(acctid);
		if (makerAccount == null) {
			return false;
		}
		Maker maker = new Maker().selectById(makerAccount.getUserid());
		if (maker == null) {
			return false;
		}
		String noticeName = "";
		String reason = "";
		if (1 == flag) {
			noticeName = "创客身份验证审核通知";
			reason = makerAccount.getRejectBusinessRegisterReason();
		} else if (2 == flag) {
			noticeName = "创客身份验证审核通知";
			reason = makerAccount.getGovernmentRejectionReasons();
		} else if (3 == flag) {
			noticeName = "创客实名认证审核通知";
		}

		String openid = maker.getOpenid();
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setUrl(commonConfig.getWeiXinLoginUrl());
		message.setTemplate_id(TEMP_AUTH_NOTIFY);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(noticeName, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("创客名-" + makerAccount.getRealname()));
		if (3 != flag) {
			data.put("keyword2", WxTempleteMessage.ValueColor.of("审核失败,原因-" + reason));
			data.put("remark", WxTempleteMessage.ValueColor.of("请重新提交审核资料,谢谢"));
		} else {
			data.put("keyword2", WxTempleteMessage.ValueColor.of("您的实名审核已通过，请点击详情提交身份验证资料"));
		}
		message.setData(data);

		sendMessage(message, makerAccount.getRealname(), EmailType.MAKER, TEMP_AUTH_NOTIFY, null);
		return true;
	}

	@Override
	public boolean makerSubmitDataNotify(int acctid) {
		MakerAccount makerAccount = new MakerAccount().selectById(acctid);
		if (makerAccount == null) {
			return false;
		}
		Maker maker = new Maker().selectById(makerAccount.getUserid());
		if (maker == null) {
			return false;
		}
		String detail = "共青城创客" + makerAccount.getRealname() + "提交了视频签名资料，请去审核!";
		/*
		标题认证通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		认证详情：{{keyword1.DATA}}
		认证结果：{{keyword2.DATA}}
		{{remark.DATA}}
		*/
		notificationConfig.getCustomerAgents().forEach(openid -> {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_AUTH_NOTIFY);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("创客提交视频资料审核通知", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of(detail));
			data.put("keyword2", WxTempleteMessage.ValueColor.of("资料提交，等待审核"));
			data.put("remark", WxTempleteMessage.ValueColor.of("请尽快审核，谢谢！"));
			message.setData(data);
			sendMessage(message, makerAccount.getRealname(), EmailType.OTHER, TEMP_AUTH_NOTIFY, null);
		});
		return true;
	}

	@Override
	public boolean notifyJiugeOfflineCrowdSourceProjectPaying(int projectId) {

		CrowdsourceProject crowdsourceProject = new CrowdsourceProject().selectById(projectId);
		if (null == crowdsourceProject) {
			return false;
		}
		Company company = new Company().selectById(crowdsourceProject.getCompid());
		if (null == company) {
			return false;
		}
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String payAmount = crowdsourceProject.getProjectTotalPayableAmount().setScale(2, RoundingMode.DOWN).toString();
		String result = "应付总金额" + payAmount + "元";
		String remark = "请尽快处理!";
		// 天津市南开区李含创客企业管理咨询工作室
		String openid = "oB8CR0Y8d_AK9BFtDW0vvzdJjTNw";
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("智众包项目平台线下支付通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("企业名称-" + company.getCompname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(result));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);

		sendMessage(message, "天津市南开区李含创客企业管理咨询工作室", EmailType.OTHER, TEMP_SEND_NOTICE, null);
		return true;
	}

	@Override
	public boolean reminderToSubmitData(String openid, String name, Integer userId) {
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		message.setUrl(commonConfig.getWeiXinLoginUrl());
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 平台提示", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("温馨提示"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of("【温馨提示】您提交的平台注册资料已认证通过，请尽快完成视频认证，点击进入。"));
		message.setData(data);
		sendMessage(message, name, EmailType.MAKER, TEMP_SEND_NOTICE, userId);
		return true;
	}

	@Override
	public boolean urgeCompanyUploadProjectFile(String openid, String text, String name, Integer compId) {
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 平台提示", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("温馨提示"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(text + ",请及时上传！如有问题请咨询JUDY，或拨打全国客服电话17710090008。"));
		message.setData(data);
		sendMessage(message, name, EmailType.COMP, TEMP_SEND_NOTICE, compId);
		return true;
	}

	@Override
	public boolean makerAppreciationServiceApplyNotice(int id, int typeId) {
        /*
        获取创客工作室名
         */
		MakerStudio makerStudio = new MakerStudio().selectById(id);
		String name;
		String temp = makerStudio.getUsername();
		if ("".equals(temp.trim())) {
			return false;
		} else {
			name = "创客工作室 - " + temp;
		}
		//发送申请增值服务通知 赵菲、胡刚、夏伦聪
		if (whetherTestConfig.isTest()) {
			ArrayList<String> list = new ArrayList<>();
			list.add("oB8CR0cn_ACYVud-VWlFnoZZE6ZM");
			sendNoticeToInsider(list, name, typeId);
		} else {
			sendNoticeToInsider(notificationConfig.getAppreciationServices(), name, typeId);
		}

		return true;
	}

	@Override
	public boolean companyAppreciationServiceApplyNotice(int id, int typeId) {
        /*
        获取企业名
         */
		Company company = new Company().selectById(id);
		String name;
		String temp = company.getCompname();
		if ("".equals(temp.trim())) {
			return false;
		} else {
			name = "企业 - " + temp;
		}
		//发送申请增值服务通知 赵菲、胡刚、夏伦聪
		if (whetherTestConfig.isTest()) {
			ArrayList<String> list = new ArrayList<>();
			list.add("oB8CR0cn_ACYVud-VWlFnoZZE6ZM");
			sendNoticeToInsider(list, name, typeId);
		} else {
			sendNoticeToInsider(notificationConfig.getAppreciationServices(), name, typeId);
		}

		return true;
	}

	@Override
	public boolean makerAppreciationServiceAcceptedNotice(int typeId, int id, String result, String remark) {
        /*
        获取创客的openid，判断是否存在 将备注判断是否为空
         */
		String openid = "";
		Maker maker = new Maker().selectById(id);
		MakerStudio makerStudio = new MakerStudio().selectById(id);
		if (null == (openid = maker.getOpenid())) {
			return false;
		}
		if (null == remark || "".equals(remark.trim()) || "驳回原因：".equals(remark.trim())) {
			remark = " ";
		}
		MakerAccount makerAccount = new MakerAccount().selectOne(Condition.create().eq("userid", maker.getUserid()));
		if (makerAccount == null) return false;
		sendNoticeToMakerOrCompany(typeId, openid, result, remark, makerAccount.getRealname(), EmailType.MAKER, makerAccount.getUserid());

		return true;
	}

	@Override
	public boolean companyAppreciationServiceAcceptedNotice(int typeId, int id, String result, String remark) {
        /*
        获取企业的openid，判断是否存在 将备注判断是否为空
         */
		String openid = "";
		Company company = new Company().selectById(id);
		if (null == (openid = company.getOpenid())) {
			return false;
		} else if (null == remark || "".equals(remark.trim()) || "驳回原因：".equals(remark.trim())) {
			remark = " ";
		}
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		sendNoticeToMakerOrCompany(typeId, openid, result, remark, companyAccount.getRealname(), EmailType.COMP,
				companyAccount.getCompid());

		return true;
	}

	/**
	 * 发送申请增值服务通知给 赵菲、胡刚、夏伦聪
	 *
	 * @param openids 需要发送的openid
	 * @param name    企业或者创客的名字
	 * @param typeId  增值类型
	 */
	private void sendNoticeToInsider(List<String> openids, String name, int typeId) {
		openids.forEach(openid -> {
			/*
			标题业务状态变更通知
			行业IT科技 - 互联网|电子商务
			详细内容{{first.DATA}}
			变更类型：{{keyword1.DATA}}
			变更结果：{{keyword2.DATA}}
			变更时间：{{keyword3.DATA}}
			{{remark.DATA}}
			*/

			/*
			  标题：业务状态变更通知
			  详细内容：用户申请服务
			  变更类型：【增值服务】+name
			  变更结果：申请已提交，等待审核
			  变更时间：系统时间
			  备注：请尽快审核，谢谢！
			 */

			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>(5);
			data.put("first", WxTempleteMessage.ValueColor.of("用户申请服务", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of("【增值服务】 " + getAppreciationServiceType(typeId) + "\n" + name));
			data.put("keyword2", WxTempleteMessage.ValueColor.of("申请已提交，等待审核"));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
			data.put("remark", WxTempleteMessage.ValueColor.of("请尽快审核，谢谢！"));
			message.setData(data);
			sendMessage(message, "管理员", EmailType.OTHER, TEMP_STATE_CHANGED, null);
		});
	}

	/**
	 * 发送微信消息【服务受理通知】给创客或者企业
	 *
	 * @param typeId 增值类型
	 * @param openid 创客或者企业的openid
	 * @param result 结果
	 * @param remark 备注
	 */
	private void sendNoticeToMakerOrCompany(int typeId, String openid, String result, String remark, String name, Integer type,
	                                        Integer userId) {
        /*
		  标题：业务状态变更通知
		  变更类型：【申请增值服务】+name
		  变更结果：申请已审核，审核结果为：result
		  变更时间：系统时间
		  备注：
		 */
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("服务审核结果", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("【增值服务】" + getAppreciationServiceType(typeId)));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("已" + result));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);
		sendMessage(message, name, type, TEMP_STATE_CHANGED, userId);
	}

	private String getAppreciationServiceType(int id) {
		return systemDictMapper.queryDictName(id);
	}

	@Override
	public boolean sendNoticeToHuGangForServiceError(String content, int type, int solve, String involvePeople, Integer solvePeopleId,
	                                                 String followContent) {

		String changeType = "";
		String changeResult = "";
		String solvePeople = managerMapper.selectById(solvePeopleId).getManagername();
		if (!StringUtil.isEmpty(followContent)) {
			followContent = " ；跟进内容：" + followContent;
		} else {
			followContent = "";
		}
		if (StringUtil.isEmpty(solvePeople)) {
			return false;
		}
		switch (type) {
			case 1:
				changeType = "【新增】";
				break;
			case 2:
				changeType = "【解决】";
				break;
			case 3:
				changeType = "【跟进】";
				break;
			default:
				return false;
		}
		switch (solve) {
			case 0:
				changeResult = "未解决";
				break;
			case 1:
				changeResult = "已解决";
				break;
			default:
				return false;
		}

        /*
              标题：业务状态变更通知
			  详细内容：客服异常事务通知
			  变更类型：【新增/解决/跟进 客服异常记录】
			           ******
			  变更结果：已解决/未解决
			  变更时间：系统时间
			  备注：涉及人员：***，*** 解决人员：***
		*/
		List<String> openids = Lists.newArrayList();
		HashMap<String, String> hashMap = new HashMap<>();

		if (ContextUtil.isProd()) {
			openids.addAll(notificationConfig.getTestNoticeOpenids());
			hashMap.put("oB8CR0RKF9pUc1Y_4TYKwYxLoNzY", "胡刚");
			hashMap.put("oB8CR0XDze6awrKTQVaPmVleg2ys", "张俊");
			hashMap.put("oB8CR0SpZRdPAD67vRLAnuadWjus", "tina");
			hashMap.put("oB8CR0S6BNxjOOzgHKzkLqlK8LYA", "bob");
		} else {
			openids.add("oW1eL0ekPVUCCmpQLl6jR_iqzJ5s");
			hashMap.put("oW1eL0ekPVUCCmpQLl6jR_iqzJ5s", "管理员");
		}
		for (String openid : openids) {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("客服异常事务通知", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of(changeType + "\n" + content));
			data.put("keyword2", WxTempleteMessage.ValueColor.of(changeResult));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
			data.put("remark", WxTempleteMessage.ValueColor.of("涉及人员：" + involvePeople + "; 解决人员：" + solvePeople + followContent));
			message.setData(data);
			message.setTouser(openid);
			sendMessage(message, hashMap.get(openid), EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}

		return true;
	}

	@Override
	public boolean sendNoticeToCompanyAndZhouYuchenForOpenAnAccount(Integer compId, String makerName, String studioName) {
		List<String> openids = new ArrayList<>();
		Company company = companyMapper.selectById(compId);
		CompanyAccount companyAccount = new CompanyAccount().selectOne(Condition.create().eq("compid", company.getCompid()));
		if (companyAccount == null) return false;
		if (null == company) {
			return false;
		}
		if (whetherTestConfig.isTest()) {
			openids.add("oW1eL0ZSS1qljBUCeXwG3azzrpLs");
			openids.add("oW1eL0ekPVUCCmpQLl6jR_iqzJ5s");
		} else {
			openids.add(company.getOpenid());
			openids.add(notificationConfig.getZhouyuchen());
		}

		openids.forEach(openid -> {
			/*
			标题业务状态变更通知
			行业IT科技 - 互联网|电子商务
			详细内容{{first.DATA}}
			变更类型：{{keyword1.DATA}}
			变更结果：{{keyword2.DATA}}
			变更时间：{{keyword3.DATA}}
			{{remark.DATA}}
			*/

			/*
			  标题：业务状态变更通知
			  详细内容：工商审核通过
			  变更类型：【工商审核通过】
			  变更结果：您好，**创客的工作室，工商部门已审核通过，
			           工作室名称为“*******”，您可开始进行交易前
			           的准备工作，预计3-5个工作日可下发执照。
			  变更时间：系统时间
			  备注：
			 */
            		/*
			  标题：业务状态变更通知
			  详细内容：工商审核通过
			  变更类型：【工商审核通过】
			  变更结果：***公司的创客**，已在工商部门审核通过，工作室名称为“*******”，预计3-5个工作日下发执照，请提前与企业沟通做好交易前的准备工作。
			  变更时间：系统时间
			  备注：
			 */

			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>(5);
			data.put("first", WxTempleteMessage.ValueColor.of("工商审核通过", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of("【工商审核通过】"));
			data.put("keyword2",
					WxTempleteMessage.ValueColor.of("您好，" + makerName + "创客的工作室，工商部门已审核通过，工作室名称为”" + studioName + "”，预计3-5个工作日可下发执照。"));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
			data.put("remark", WxTempleteMessage.ValueColor.of(""));
			message.setData(data);
			if (openid.equals("oB8CR0ek7b-bMmkrZ88gMBMNhs-I")) {
				sendMessage(message, "周雨辰", EmailType.OTHER, TEMP_STATE_CHANGED, null);
			} else {
				sendMessage(message, companyAccount.getRealname(), EmailType.OTHER, TEMP_STATE_CHANGED, null);
			}

		});

		return true;
	}

	@Override
	public boolean notifyWuhuMakerTaxVideo(MakerDetailDto makerDetailDto) {
		if (makerDetailDto == null) return false;
		String openid = makerDetailDto.getOpenid();
		String url = "http://m.zhduoduo.com/login";

			/*
			标题业务状态变更通知
			行业IT科技 - 互联网|电子商务
			详细内容{{first.DATA}}
			变更类型：{{keyword1.DATA}}
			变更结果：{{keyword2.DATA}}
			变更时间：{{keyword3.DATA}}
			{{remark.DATA}}
			*/

            /*
			  标题：业务状态变更通知
			  详细内容：工商审核通过
			  变更类型：【工商审核通过】
			  变更结果：***公司的创客**，已在工商部门审核通过，工作室名称为“*******”，预计-5下发执照，请提前与企业沟通做好交易前的准备工作。
			  变更时间：系统时间
			  备注：
			 */

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setUrl(url);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>(5);
		data.put("first", WxTempleteMessage.ValueColor.of("工商审核通过", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("【工商审核通过】"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("请联系客服，协助您操作定税视频的录制及上传。"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, makerDetailDto.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, makerDetailDto.getUserid());

		return true;
	}

	/**
	 * 提醒内容，发票类型
	 *
	 * @param content     提醒内容
	 * @param invoiceType 发票类型：1：成本票创客，2：众包发票
	 * @return
	 */
	@Override
	public boolean invoiceOverdueNotice(String content, Integer invoiceType) {
		if (StringUtil.isEmpty(content)) {
			return false;
		}
		String title = "";
		List<String> list = new ArrayList<>();
		if (invoiceType == 1) {
			title = "【成本票已逾期】";
			list.add(notificationConfig.getTestNoticeOpenids().get(2));//"tina";
			list.add(notificationConfig.getCustomerAgents().get(0));//"赵菲"
		} else {
			title = "【发票已逾期】";
			list.add(notificationConfig.getTestNoticeOpenids().get(2));//"tina";
			list.add(notificationConfig.getFinanceList().get(0));//"纪锦娟";
			list.add(notificationConfig.getCustomerAgents().get(3));//"符嘉琳";
		}

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		for (String openid : list) {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(TEMP_STATE_CHANGED);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("发票逾期提醒", "#000000"));
			data.put("keyword1", WxTempleteMessage.ValueColor.of(title));
			data.put("keyword2", WxTempleteMessage.ValueColor.of(content));
			data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
			data.put("remark", WxTempleteMessage.ValueColor.of(""));
			message.setData(data);
			sendMessage(message, openid, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		}
		return true;
	}

	@Override
	public boolean notifyMakerProjectBidResult(MakerDetailDto maker, CompanyProject project, MakerZddProjectBid bid) {

		String result = "";
		String remark = "";
		if (bid.getState() == MakerBidState.VERIFY_FAILED) {
			result = "竞标失败";
			remark = bid.getVerifyRemark();
		} else if (bid.getState() == MakerBidState.SUCCESS) {
			result = "竞标成功，祝贺您";
		} else {
			return false;
		}

        /*
		  标题：业务状态变更通知
		  变更类型：【申请增值服务】+name
		  变更结果：申请已审核，审核结果为：result
		  变更时间：系统时间
		  备注：
		 */
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(maker.getOpenid());
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 项目竞标结果通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("竞标项目-" + project.getProjectname()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(result));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);
		sendMessage(message, maker.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, maker.getUserid());

		return true;
	}

	@Override
	public boolean notifyCompanyVerifyZddProjectBid(CompanyProject project, MakerZddProjectBid bid) {

		Integer compid = project.getCompid();
		Company company = companyMapper.selectById(compid);
		if (company == null) return false;
		MakerStudio makerStudio = new MakerStudio().selectById(bid.getUserid());

		/*
		  标题：业务状态变更通知
		  变更类型：【申请增值服务】+name
		  变更结果：申请已审核，审核结果为：result
		  变更时间：系统时间
		  备注：
		 */
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(company.getOpenid());
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 项目竞标通知", "#000000"));
		data.put("keyword1",
				WxTempleteMessage.ValueColor.of("创客【" + makerStudio.getUsername() + "】，竞标项目【" + project.getProjectname() + "】"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("请及时审核"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED, company.getCompid());

		return true;
	}

	@Override
	public boolean notifyMakerDispatchBid(MakerDetailDto maker, CompanyProject project) {
		String result = "竞标成功。";
		String remark = "";

        /*
		  标题：业务状态变更通知
		  变更类型：【申请增值服务】+name
		  变更结果：申请已审核，审核结果为：result
		  变更时间：系统时间
		  备注：
		 */
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(maker.getOpenid());
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 项目竞标结果通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("竞标项目【" + project.getProjectname() + "】"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(result));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(remark));
		message.setData(data);
		sendMessage(message, maker.getRealname(), EmailType.MAKER, TEMP_STATE_CHANGED, maker.getUserid());

		return true;
	}

	@Override
	public boolean enterpriseApplicationDorRefund(String openid, int type, String cause, BigDecimal amount,int businessManagerId ) {

		if(StringUtils.isBlank(openid)){
			return false;
		}
		String first;
		String changeResult;
		String changeType;
		if( 1 == type){
			BusinessManager businessManager = new BusinessManager().selectById(businessManagerId);
			first = "余额提现取消";
			changeType = "余额提现取消";
			changeResult = "贵司申请的余额提现"+amount.toString()+"元已取消，取消原因："+cause+"，如有问题请联系专业顾问： "+businessManager.getBusinessManager()+businessManager.getPhone();
		} else if(2 == type){
			first = "余额提现成功";
			changeType = "余额提现申请";
			changeResult = "贵司申请的余额提现"+amount.toString()+"元，已操作成功，具体以银行到账为准，请注意查收。";
		} else {
			first = "企业申请退款";
			changeType = "企业申请退款";
			changeResult = cause+"企业申请余额提现"+amount.toString()+"元";
		}

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(first, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(changeType));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(changeResult));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_6)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, null, null, TEMP_STATE_CHANGED, null);
		return true;
	}

	@Override
	public boolean costTicketOverdue(String content) {
		if (StringUtil.isEmpty(content)) {
			return false;
		}

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		String openid = "oB8CR0Y8d_AK9BFtDW0vvzdJjTNw";
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("发票逾期提醒", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("智零工成本票逾期"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(content));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, openid, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		return true;
	}

	@Override
	public boolean overdueTaxCertificate(String content, String openid) {
		if (StringUtil.isEmpty(content)) {
			return false;
		}

		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("完税凭证逾期提醒", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("智零工完税凭证逾期"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(content));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, openid, EmailType.OTHER, TEMP_STATE_CHANGED, null);
		return true;
	}
	@Override
	public boolean makerMessageNotification(int userId,String content) {
		Maker maker = new Maker().selectById(userId);
		if (null == maker){
			return false;
		}
		/*
		标题业务处理结果通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(maker.getOpenid());
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of(" 平台提示", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("温馨提示"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(content));
		message.setData(data);
		sendMessage(message, "创客消息通知", EmailType.MAKER, TEMP_SEND_NOTICE, userId);
		return true;
	}

	@Override
	public boolean enterpriseProjectAcceptanceNotice(ProjectCompanyDto dto) {
		String url;
		if (ContextUtil.isProd()){
			url = "https://m.zhduoduo.com/companyProjectList";
		}else {
			url = "http://zdd2.info666.com/companyProjectList";
		}
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(dto.getOpenid());
		message.setTemplate_id(TEMP_STATE_CHANGED);
		message.setUrl(url);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("【温馨提示】贵司有"+dto.getQuantity()+"笔订单已完成，请及时验收！", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("项目进度更新"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("创客完成项目,等待验收"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.DateToStr(DateUtil.FORMAT_STYLE_6, new Date())));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, dto.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED,dto.getCompid());
		return true;
	}

	@Override
	public boolean sendTina(StringBuilder message) {
		String url;
		if (ContextUtil.isProd()){
			url = "https://m.zhduoduo.com/companyProjectList";
		}else {
			url = "http://zdd2.info666.com/companyProjectList";
		}
		/*
		标题业务状态变更通知
		行业IT科技 - 互联网|电子商务
		详细内容{{first.DATA}}
		变更类型：{{keyword1.DATA}}
		变更结果：{{keyword2.DATA}}
		变更时间：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		WxTempleteMessage messages = new WxTempleteMessage();
		messages.setTouser("oB8CR0SpZRdPAD67vRLAnuadWjus");
		messages.setTemplate_id(TEMP_STATE_CHANGED);
		messages.setUrl(url);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("【温馨提示】项目未验收", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(message.toString()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of("完成项目,等待验收"));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.DateToStr(DateUtil.FORMAT_STYLE_6, new Date())));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		messages.setData(data);
		sendMessage(messages, "夏伦聪", EmailType.OTHER, TEMP_STATE_CHANGED,null);
		return true;
	}

	/**
	 * 智零工业务发布后发微信通知给李含
	 * @param projectId
	 */
	@Override
	public void notifyWorkerAfterOddJobSubmit(int projectId) {
		CrowdsourceProject cp = new CrowdsourceProject().selectById(projectId);
		if (cp == null) {
			return;
		}

		String openid = notificationConfig.getFinanceList().get(1);
		/*
		{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String content = cp.getCompname() + " 企业发布智零工业务，金额：" + cp.getProjectTotalAmount() + "元，请及时联系对方开票。";

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("智零工发布通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(cp.getProjectName()));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(content));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);

		sendMessage(message, "candy", EmailType.OTHER, TEMP_STATE_CHANGED, null);
	}

	/**
	 * 企业合同审核完成，发送通过/驳回通知
	 */
	@Override
	public void notifyCompanyContractAudit(CompanyEntrustFile companyEntrustFile) {
		if (companyEntrustFile == null) return;
		Integer compid = companyEntrustFile.getCompid();
		Company company = companyMapper.selectById(compid);
		if (company == null) return;

		String first = "";
		String key2 = "";
		if (companyEntrustFile.getAuditState() == 2) {
//			first = "【温馨提示】贵司在线签约已生效，即可登陆管理端进行发单操作啦！";
			key2 = "贵司在线签约已生效，即可登陆管理端进行发单操作啦！";
		} else {
//			first = "【温馨提示】贵司在线签约未通过，请登录 管理端重新签约。失败原因：" + companyEntrustFile.getAuditMsg() + "。";
			key2 = "贵司在线签约未通过，请登录 管理端重新签约。失败原因：" + companyEntrustFile.getAuditMsg() + "。";
		}

		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(company.getOpenid());
		message.setTemplate_id(TEMP_STATE_CHANGED);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
//		data.put("first", WxTempleteMessage.ValueColor.of(first, "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of("在线签约"));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(key2));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(DateUtil.getNowTimeString()));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, company.getCompname(), EmailType.COMP, TEMP_STATE_CHANGED, compid);
	}

	@Override
	public void informTheTreasurer(String content) {
		/*
		{{first.DATA}}
		系统名称：{{keyword1.DATA}}
		完成时间：{{keyword2.DATA}}
		结果描述：{{keyword3.DATA}}
		{{remark.DATA}}
		*/
		String openid = "oB8CR0QLQBed9zjqV7Evcvq5PZx8";
		WxTempleteMessage message = new WxTempleteMessage();
		message.setTouser(openid);
		message.setTemplate_id(TEMP_SEND_NOTICE);
		Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
		data.put("first", WxTempleteMessage.ValueColor.of("企业合同通知", "#000000"));
		data.put("keyword1", WxTempleteMessage.ValueColor.of(content));
		data.put("keyword2", WxTempleteMessage.ValueColor.of(DateUtil.getString(new Date(), DateUtil.FORMAT_STYLE_1)));
		data.put("keyword3", WxTempleteMessage.ValueColor.of(""));
		data.put("remark", WxTempleteMessage.ValueColor.of(""));
		message.setData(data);
		sendMessage(message, "刘晓语", EmailType.OTHER, TEMP_SEND_NOTICE, null);
	}

	@Override
	public void invoiceApplyNotifyKefu(TaxerInvoice taxerInvoice) {
		// Phoenix + tina夏伦聪 + 汤圆tangYuan
		Map<String,String> openids = new HashMap<>();
		openids.put("oc7pF6aVMVwSo8TOsnIiePWo5cj4","Phoenix");
		openids.put("oc7pF6Wu-wu91sASP5Mjqw1xuCZY","夏伦聪");
		openids.put("oc7pF6bEs2OMcON24c9njUGOfeb4","汤圆");
		openids.put("oc7pF6SUjKLYDsCX9dWVqrxd0jeY","ruby");

		for (String openid:openids.keySet()) {
			WxTempleteMessage message = new WxTempleteMessage();
			message.setTouser(openid);
			message.setTemplate_id(INVOICE_APPLY_NOTIFY_TEMPLATE);
			Map<String, WxTempleteMessage.ValueColor> data = new HashMap<>();
			data.put("first", WxTempleteMessage.ValueColor.of("发票开具申请通知", "#000000"));
			data.put("thing6", WxTempleteMessage.ValueColor.of(taxerInvoice.getUsername()));
			data.put("amount1", WxTempleteMessage.ValueColor.of(NumberUtil.formatFloat2_0(taxerInvoice.getAmount().floatValue())));
			message.setData(data);
			sendMessage(message, openids.get(openid), EmailType.OTHER, TEMP_SEND_NOTICE, null);
		}
	}
}
